Hệ thống quản lý trường học bằng PHP / MySQLi
1 <?php
2 if(isset($_POST['phone']) && isset($_POST['message']))
3 {
4 $phone = $_POST['phone'];
5 $message = $_POST['message'];
6
7 echo "$phone, $message";
8
9 sendSMS($phone, $message);
10 }
11 else
12 {
13 echo "Enter all details";
14 }
15
16 function sendSMS($phonenumber, $message)
17 {
18 //initialize parameters
19 $messageId = "";
20 $cost = 0;
21
22 $user = "aberdare";
23 $apikey = "212ae38a97a4dc2c1ef0fccfdb3324ac";
24 $sender = "MOBILESASA";
25
26 $ch = curl_init();
27 $url = "http://mobilesasa.com/sendsmspost.php";
28 curl_setopt($ch, CURLOPT_URL,$url);
29 curl_setopt($ch, CURLOPT_POST, true); //Tell cURL you want to post something
30 curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); //set this to false if you are getting the error message -SSL certificate problem: unable to get local issuer certificate
31 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
32 // Define what you want to post
33 curl_setopt($ch, CURLOPT_POSTFIELDS, 'user='.$user.'&apikey='.$apikey.'&sender='.$sender.'&message='.$message.'&phonenumber='.$phonenumber);
34 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the output in string format
35 $output = curl_exec ($ch); // Execute
36
37 curl_close ($ch); // Close cURL handle
38
39 if($output != false)
40 {
41 $values = explode('|', $output);
42
43 if($values[0] === '1701')//if request is successful
44 {
45 $phonenumber = $values[1];
46 $messageId = $values[2];
47 $cost = $values[3];
48
49 }
50 else//if it fails for some reason
51 {
52 $reason = $values[1];
53 echo $reason;
54 }
55 }
56 else
57 {
58 echo "Error ".mysqli_error($link)."<br/>";
59 }
60
61 echo $phonenumber.",".$messageId.",".$cost."<br/>";
62 }
63
64 ?>